package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormMemoryInDetailDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormMemoryInDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormMemoryInDetailConverter {

    public static FlowFormMemoryInDetailDto do2Dto(FlowFormMemoryInDetail domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        FlowFormMemoryInDetailDto dto = FlowFormMemoryInDetailMapper.INSTANCE.do2Dto(domain);
        return dto;
    }

    public static List<FlowFormMemoryInDetailDto> do2Dto(List<FlowFormMemoryInDetail> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormMemoryInDetailConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormMemoryInDetail dto2Do(FlowFormMemoryInDetailDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        FlowFormMemoryInDetail domain = FlowFormMemoryInDetailMapper.INSTANCE.dto2Do(dto);
        return domain;
    }

    public static List<FlowFormMemoryInDetail> dto2Do(List<FlowFormMemoryInDetailDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormMemoryInDetailConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormMemoryInDetailMapper {

        FlowFormMemoryInDetailMapper INSTANCE = Mappers.getMapper(FlowFormMemoryInDetailMapper.class);

        FlowFormMemoryInDetailDto do2Dto(FlowFormMemoryInDetail domain);

        List<FlowFormMemoryInDetailDto> do2Dto(List<FlowFormMemoryInDetail> domain);

        FlowFormMemoryInDetail dto2Do(FlowFormMemoryInDetailDto dto);

        List<FlowFormMemoryInDetail> dto2Do(List<FlowFormMemoryInDetailDto> dto);
    }
}
